package com.projectw.service.impl;

import com.projectw.dao.TestDemoMapper;
import com.projectw.po.TestDemo;
import com.projectw.po.TestDemoExample;
import com.projectw.service.PwService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Peter_Wang on 2018/8/20.
 */
@Service
public class PwServiceImpl implements PwService {

    @Autowired
    private TestDemoMapper testDemoMapper;

    @Override
    public String selectTestDemo(String param){
        String result = "";
        TestDemoExample example = new TestDemoExample();
        TestDemoExample.Criteria criteria = example.createCriteria();
        criteria.andColumnNameEqualTo(param);
        List<TestDemo> testDemoList = this.testDemoMapper.selectByExample(example);
        if(testDemoList!=null && testDemoList.size()>0){
            result = testDemoList.get(0).getColumnValue();
        }
        return "add value: "+result;
    }

    @Override
    public boolean insertTestDemo(TestDemo testDemo){
        this.testDemoMapper.insertSelective(testDemo);
        return true;
    }

    @Override
    public boolean updateTestDemo(TestDemo testDemo){
        this.testDemoMapper.updateByPrimaryKeySelective(testDemo);
        return true;
    }
}
